//
//  MyFriendController.m
//  LiquorChain
//
//  Created by apple on 2018/12/26.
//  Copyright © 2018年 王冬. All rights reserved.
//

#import "MyFriendController.h"
#import "FriendViewCell.h"
@interface MyFriendController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;
@end

@implementation MyFriendController

static NSString *CellIdentifier = @"friendCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的粉丝";
    self.tableView =[[UITableView alloc]initWithFrame:CGRectMake(0, kNavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kNavBarHeight-kIPhoneXBottomHeight) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
    [self.tableView registerNib:[UINib nibWithNibName:@"FriendViewCell" bundle:nil] forCellReuseIdentifier:CellIdentifier];
    UIView *headView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 86)];
    UILabel * numberLabel =[[UILabel alloc]init];
    [headView addSubview:numberLabel];
    numberLabel.text = @"123";
    numberLabel.textColor =[UIColor whiteColor];
    numberLabel.font =[UIFont systemFontOfSize:30];
    [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.left.mas_equalTo(15);
        make.height.mas_equalTo(23);
    }];
    UILabel *fanLabel =[[UILabel alloc]init];
    [headView addSubview:fanLabel];
    fanLabel.text = @"粉丝总数";
    fanLabel.font =[UIFont systemFontOfSize:14];
    fanLabel.textColor =[UIColor whiteColor];
    [fanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(numberLabel.mas_bottom).with.offset(6);
        make.left.mas_equalTo(15);
        make.height.mas_equalTo(13);
    }];
    UIButton *fanBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [headView addSubview:fanBtn];
    [fanBtn setTitle:@"什么是合格粉丝？" forState:UIControlStateNormal];
    fanBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [fanBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [fanBtn addTarget:self action:@selector(fanClick:) forControlEvents:UIControlEventTouchUpInside];
    [fanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(12);
    }];
    headView.backgroundColor = RGBA(202.0, 19.0, 85.0, 1);
    self.tableView.tableHeaderView = headView;
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.tableView];
    
    // Do any additional setup after loading the view.
}
-(void)fanClick:(UIButton *)sender{
    NSLog(@"123");
    // 合格粉丝就是邀请的朋友实名注册、下载app、登录和创建数字钱包，否则邀请的酿力奖励计入未生效之列，待朋友成为合格粉丝后才生效和参与圣酒分配；
    
    
    //创建控制器
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"什么是合格粉丝" message:
@"                                                                       合格粉丝就是邀请的朋友实名注册、下载app、登录和创建数字钱包，否则邀请的酿力奖励计入未生效之列，待朋友成为合格粉丝后才生效和参与圣酒分配                                                        " preferredStyle:UIAlertControllerStyleAlert];
    //创建添加按钮（可以写事件，也可以不写），可以创建多个按钮
    UIAlertAction *OKbtn = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
//    //修改Title
//
//    //设置行间距
//    NSMutableParagraphStyle *titleParagraphStyle = [[NSMutableParagraphStyle alloc]init];
//    titleParagraphStyle.alignment = NSTextAlignmentCenter;
//    titleParagraphStyle.lineSpacing = 20;//行间距
//
//    NSDictionary *titleAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:17], NSParagraphStyleAttributeName:titleParagraphStyle };//字体大小 行间距  颜色
//
//      [alertVC setValue: [[NSAttributedString alloc]initWithString:alertVC.title attributes:titleAttributes] forKey:@"attributedTitle"];
    //修改message
    //设置行间距
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    paragraphStyle.alignment = NSTextAlignmentLeft;
    paragraphStyle.lineSpacing = 10;//行间距
   

    NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:12], NSParagraphStyleAttributeName:paragraphStyle};//字体大小 行间距  颜色
    
    
    [alertVC setValue: [[NSAttributedString alloc]initWithString:alertVC.message attributes:attributes] forKey:@"attributedMessage"];
   // [alertVC setValue:alertControllerMessageStr forKey:@"attributedMessage"];
    

    
    //backImage
    UIImage *accessoryImage = [UIImage imageNamed:@"backImage1"];
    
    accessoryImage = [accessoryImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    [OKbtn setValue:accessoryImage forKey:@"image"];

    [OKbtn setValue:[UIColor whiteColor] forKey:@"_titleTextColor"];
    
    
    //添加按钮到alertVC上，并模态出来
    [alertVC addAction:OKbtn];
    [self presentViewController:alertVC animated:YES completion:nil];
    

    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 15;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}
    
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    FriendViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
